<?php
/**
 * Created by PhpStorm OF Administrator.
 * User: YUYI
 * Date: 2018/8/8 0008
 * Time: 下午 3:20
 * Administrator
 */

namespace app\alipay\controller;


use app\common\service\DateService;
use app\common\service\SysConfigService;
use app\common\util\PostUtil;
use Pay\Pay;
use think\Controller;
use think\Exception;

class Index extends Controller
{
    use PostUtil;
    const PRIVATE_KEY = 'MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCPv5uLBlHhZqfneX5U4RbsyOfixsPjSMFmV9gcCf9/L2y687bB70thTAYw4JqpLkP9cDra6dWhbxyWOv8/0FBiT2VjRYcSST2m8B/HkQz1LNQ1cTuj/Eao59SSYxxxD8hQXUxO3S+FTmMRJIYlRYFJWKM05NCrAjt/p6t8g94bmbDuw3WdnTX5Bq1EUBDQHTRlJgJXwfnqkfV+N639loELYcCtjglQM/dy3JsMWtjEgSq+ehLudSFvNCHFPAdlUmhzbNI1ylOX9bdcpn9mhpmoTECZMJpUyShkSbXBDebkaIiRfUgBLCror7tcI2MERzsERJ5I1P4BKMyhgTUULvsvAgMBAAECggEAaTeUwIQVtuiPCc1R/Qrs3tCHeuSGSXzdou21j4B59TxfV9A/+2AOSt98wJYGXsMwnPdi/Q2fgxRzVjtEzg7KZ8s5qRohLe9SIzkr6cVwOJ1hjuSdBQEJL2TRoXzOOquUsc44ppkbyXWA6fFUB0ACzA8HFxZM7n8p0dyGlxNmpcgWc7sqrEqhvgkcHUnL3aPiVlRJFD/euMRZpxwhxp+UWbze+WPd51NoqGAMQWY3NyA0EQdnSFUJscixC93bcKdefkshFdr2wgDFPOZMmYhu1w/MYkh7IqUWq8IRXEw29LBO+veVEyOUdMfSolmEZGLKv9LNEFRPZVwwPCkHL9bkkQKBgQDB6l/qOGNG/7jlV7y0ay2FuyQPqzAsDlt7QAqblfH+CmgHGgx51hRaHNj1vm3QXoF6/nWZfxJ2RNDt2h635dDs9fGpadd5oY8JkaaL0yu2zrHgL6CYXaUpXTIcZZqjv2WJX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NcpTl/W3XKZ/ZoaZqExAmTCaVMkoZEm1wQ3m5GiIkX1IASwq6K+7XCNjBEc7BESeSNT+ASjMoYE1FC77LwIDAQAB';
    public function index(){
        $config = [
            // 支付宝支付参数
            'alipay' => [
                'debug'         => true,
                'app_id'        => SysConfigService::getSysConfig(''), // 应用ID
                'public_key'    => self::PUBLIC_KEY, // 支付宝公钥(1行填写)
                'private_key'   => self::PRIVATE_KEY, // 支付宝私钥(1行填写)
                'notify_url'    => 'http://www.vovoqi.com/alipay/index/notify', // 支付通知URL
            ]
        ];
        $pay = new Pay($config);
        $options = $pay->driver('alipay')->gateway('scan')->apply([
            'out_trade_no'=>'vo'.time()
            ,'total_amount'=>'1'
            ,'subject'=>urlencode('商品'.rand(1000,9999))
        ]);
        var_dump($options);
    }
}